/**
 * 单例模式的对象，全局变量类，保存在SoundSetting页里设置的一些变量数据
 */


export class GlobalVariable {
  private static instance: GlobalVariable;
  /**
   * 关于是否进行语音播报的4个全局变量，对应SoundSetting的4个按钮
   */
  private driverHelperSwitch: boolean;
  private behaviorSwitch: boolean;
  private vSwitch: boolean;
  private tiredSwitch: boolean;
  private data: String[] =[];    //异常行为数据，以字符串数组形式存放
  private currentData: String ="";    //目前最新的一条数据，用来判断是否需要挑和改变动图
  private flag: number = 0;    //异常行为数据，以字符串数组形式存放

  private constructor() {}

  public static getInstance(): GlobalVariable {
    if (!GlobalVariable.instance) {
      GlobalVariable.instance = new GlobalVariable();
    }
    return GlobalVariable.instance;
  }

  public setdriverHelperSwitch(value: boolean): void {
    this.driverHelperSwitch = value;
  }

  public getdriverHelperSwitch(): boolean {
    return this.driverHelperSwitch;
  }


  public setbehaviorSwitch(value: boolean): void {
    this.behaviorSwitch = value;
  }

  public getbehaviorSwitch(): boolean {
    return this.behaviorSwitch;
  }


  public setvSwitch(value: boolean): void {
    this.vSwitch = value;
  }

  public getvSwitch(): boolean {
    return this.vSwitch;
  }


  public settiredSwitch(value: boolean): void {
    this.tiredSwitch = value;
  }

  public gettiredSwitch(): boolean {
    return this.tiredSwitch;
  }


  /**
   * 存储的数据加入这一项数据
   * @param value
   */
  public setdata(value: String): void {
    //进行判断，由于UDP多次反复发送保证数据完整，必须去掉无效数据。判断依据是时间data_time一致。

    this.data.push(value);
  }

  //解析出是哪种异常行为，就跳哪种提示


  public getdata(): String[] {
    return this.data;
  }


  public setflag(value: number): void {
    this.flag = value;
  }

  public getflag(): number {
    return this.flag;
  }


  public setcurrentData(value: String): void {
    this.currentData = value;
  }

  public getcurrentData(): String {
    return this.currentData;
  }

}